package com.test1.mybatis.study.mapper;

import com.test1.mybatis.study.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserInfoMapper {
//    返回数据列表
    @Select("select * from userinfo")
    List<UserInfo> queryUserList();

    @Select("select * from userinfo where id = #{userId}")
    UserInfo userInfoById(Integer userId);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into userinfo(username,password,age,gender,phone) values(#{userName},#{password},#{age},#{gender},#{phone})")
    Integer insert(UserInfo userInfo);

    @Delete("delete from userinfo where id = #{id}")
    Integer delete(Integer id);

    @Update("update userinfo set username=#{userName},password=#{password},age=#{age} where id=#{id}")
    Integer update(UserInfo userInfo);
}
